﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Adapter_配置器_模式
{
    #region 原始行为
    public interface IMedia
    {
        void Play();
    }
    public abstract class VideoMedia : IMedia
    {
        public abstract void Play();
    }
    public class RM : VideoMedia
    {

        public override void Play()
        {
            Console.WriteLine("RM play media");
        }
    }
    public class RMVB : VideoMedia
    {
        public override void Play()
        {
            Console.WriteLine("RMVB play media");
        }
    }
    #endregion

    #region 扩展的行为和适配器
    public interface IVideoScreen
    {
        void Resize();
    }
    public abstract class VideoAdapter : IMedia, IVideoScreen
    {
        public VideoMedia _videoMedia;
        public VideoAdapter(VideoMedia videoMedia)
        {
            _videoMedia = videoMedia;

        }


        #region IVideoScreen 成员

        public abstract void Resize();

        #endregion

        #region IMedia 成员

        public void Play()
        {
            _videoMedia.Play();
        }

        #endregion
    }
    public class RMAdapter : VideoAdapter
    {
        public RMAdapter()
            : base(new RM())
        {

        }

        public override void Resize()
        {
            Console.WriteLine("RMAdapter Resize");
        }
    }
    public class RMVBAdapter : VideoAdapter
    {
        public RMVBAdapter()
            : base(new RMVB())
        {

        }
        public override void Resize()
        {
            Console.WriteLine("RMVBAdapter Resize");
        }
    }
    #endregion

    class Program
    {
        static void Main(string[] args)
        {
            VideoAdapter video = new RMAdapter();
            video.Play();
            video.Resize();
        }
    }
}
